import React , { Component } from 'react'
import {HashRouter, Switch} from 'react-router-dom'

import Auth from '../components/Auth'

import Bundle from '../loadable'

const Home= Bundle(()=>import('../containers/home'));
const Login= Bundle(()=>import('../containers/login'));
const Scene= Bundle(()=>import('../containers/scene'));
const Travel= Bundle(()=>import('../containers/travel'));
const Admin= Bundle(()=>import('../containers/admin'));
const User= Bundle(()=>import('../containers/user'));
const Poverty= Bundle(()=>import('../containers/poverty'));
const SceneUpdate= Bundle(()=>import('../containers/scene/update'));
const Food= Bundle(()=>import('../containers/foods'));
const FoodDeatils = Bundle(() => import('../containers/foods/details'))
const Store= Bundle(()=>import('../containers/store'));
const StoreDeatils= Bundle(()=>import('../containers/store/details'));
const Restaurant = Bundle(() => import('../containers/restaurant'))
const RestaurantDetails = Bundle(() => import('../containers/restaurant/details'))
const Shop = Bundle(() => import('../containers/shop'))
const ShopDetails = Bundle(() => import('../containers/shop/details'))
const Medical = Bundle(() => import('../containers/medical'))
const MedicalDetails = Bundle(() => import('../containers/medical/details'))
const History = Bundle(() => import('../containers/history'))
const HistoryDetails = Bundle(() => import('../containers/history/details'))


const routes = [
    {
        path: '/',
        auth: false,
        component: Login
    },
    {
        path: '/login',
        name: 'login',
        auth: false,
        component: Login
    },
    {
        path: '/home',
        name: 'home',
        auth: true,
        component: Home,
        childrenRoute: [
            {
                path: '/home/admin',
                name: 'admin',
                auth: true,
                component: Admin
            },
            {
                path: '/home/travel',
                name: 'travel',
                auth: true,
                component: Travel
            },
            {
                path: '/home/scene',
                name: 'scene',
                auth: true,
                component: Scene
            },
            {
                path: '/home/user',
                name: 'admin',
                auth: true,
                component: User
            },
            {
                path: '/home/poverty',
                name: 'poverty',
                auth: true,
                component: Poverty
            },
            {
                path: '/home/sceneUpdate',
                name: 'sceneUpdate',
                auth: true,
                component: SceneUpdate
            },
            {
                path: '/home/medical',
                name: 'medical',
                auth: true,
                component: Medical
            },
            {
                path: '/home/medical_details',
                name: 'medical_details',
                auth: true,
                component: MedicalDetails
            },
            {
                path: '/home/history',
                name: 'history',
                auth: true,
                component: History
            },
            {
                path: '/home/history_details',
                name: 'history_details',
                auth: true,
                component: HistoryDetails
            },
            {
                path: '/home/foods',
                name: 'foods',
                auth: true,
                component: Food
            },
            {
                path: '/home/foods_details',
                name: 'foods_details',
                auth: true,
                component: FoodDeatils
            },
            {
                path: '/home/restaurants',
                name: 'restaurant',
                auth: true,
                component: Restaurant
            },
            {
                path: '/home/restaurants_details',
                name: 'restaurants_details',
                auth: true,
                component: RestaurantDetails
            },
            {
                path: '/home/shops',
                name: 'shop',
                auth: true,
                component: Shop
            },
            {
                path: '/home/shops_details',
                name: 'shops_details',
                auth: true,
                component: ShopDetails
            },
            {
                path: '/home/stores',
                name: 'stores',
                auth: true,
                component: Store
            },
            {
                path: '/home/stores_details',
                name: 'stores_details',
                auth: true,
                component: StoreDeatils
            }
        ]
    },
]

class Router extends Component {
   render() {
    return (
    <HashRouter> 
        <Switch>
               <Auth router={routes}></Auth>
            </Switch>
    </HashRouter>)
   }
}

export default  Router